<?php
namespace bankworking\BankAccount;

abstract class BankAccount {
	
	const CREDIT = 0;
	const DEPOSIT = 1;
	
	private $name;
	private $typeAccount;
	private $lihvaGodishna;
	private $period;
	private $monthlySum;
	private $availability;
	
	public function __construct($name, $typeAccount = BankAccount::CREDIT, $lihvaGodishna, $period, $monthlySum, $availability){
	
		$this->setName($name);
		$this->typeAccount = $typeAccount;
		$this->setLihvaGodishna($lihvaGodishna);
		$this->period = $period;
		$this->monthlySum = $monthlySum;
		$this->availability = $availability;
	
	
	}
	
	public function setName($newName){
		try {
			if ($newName == "" || $newName == null){
				throw new Exception("Please, enter Account name!");
			} else if (is_numeric($newName)) {
				throw new Exception("Bank name not be only numbers!");
			} else {
				$this->name = $newName;
				return true;
			}
		} catch (Exception $e) {
			echo "<p>" . $e->getMessage() . "</p>";
		}
	
	}
	
	public function getName(){
		return $this->name;
	}
	
	
	public function setLihvaGodishna($newLihva){
		try {
			if ($newLihva == "" || $newLihva == null){
				throw new Exception("Please, enter Lihva!");
			} else if ($newLihva <= 0) {
				throw new Exception("Lihva is positive numbers!");
			} else {
				$this->lihvaGodishna = $newLihva;
				return true;
			}
		} catch (Exception $e) {
			echo "<p>" . $e->getMessage() . "</p>";
		}
	
	}
	
	public function getLlihvaGodishna(){
		return $this->lihvaGodishna;
	}
	
}
